package com.reserv.util;

import java.sql.Time;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

import org.joda.time.Days;
import org.joda.time.LocalDate;

import com.google.gson.Gson;
import com.reserv.dao.ReservDAO;

public class Test {
	public static void main(String [] args) {
		//System.out.println((toTimestamp("1111-11-11")));
		
		//2015-01-01 ~ 2015-01-31
		ReservDAO dao = ReservDAO.getInstance();
		
		ArrayList<Timestamp> list = (ArrayList<Timestamp>) dao.getReservList(43);
		
		for(Timestamp ts : list) {
			System.out.print(ts);
		}
		
		
		
	}
	public static String dropSec(Timestamp ts) {
		Calendar cal = Calendar.getInstance();
		cal.setTimeInMillis(ts.getTime());
		return cal.get(Calendar.YEAR) + "-" + (cal.get(Calendar.MONTH) + 1) + "-" + cal.get(Calendar.DAY_OF_MONTH);
	
	}
	
	@SuppressWarnings("unchecked")
	static void useGson() {
		Gson gson = new Gson();
		ArrayList<String> list = new ArrayList<>();
		
		list.add("가");
		list.add("2");
		list.add("a");
		
		String json = gson.toJson(list);
		System.out.println(json);
		
		list = gson.fromJson(json, ArrayList.class);
		
		for(String str : list) {
			System.out.println(str);
		}
	}
	static Timestamp toTimestamp(String str) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Timestamp ts = null;
		try {
			Date date = sdf.parse(str + " 00:00:00");
			ts = new Timestamp(date.getTime());
			
			System.out.println(sdf.format(ts));
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return ts;
	}
	static void checkPT() {
		StringBuilder sb = new StringBuilder("FFFFFF");
		char[] pts = sb.toString().toCharArray();
		
		for(int i = 0; i < pts.length; i++) {
			if(pts[i] == 'T')
				System.out.println(i + "회차 시간은 예약중입니다.");
			if(pts[i] == 'F')
				System.out.println(i + "회차 시간은 예약가능합니다.");
		}
		System.out.println("------------------------------------------------");
		
		//6번째 시간 예약
		//pts[5] = 'T';
		sb.replace(6, 6, "T");
		pts = sb.toString().toCharArray();
		for(int i = 0; i < pts.length; i++) {
			if(pts[i] == 'T')
				System.out.println(i + "회차 시간은 예약중입니다.");
			if(pts[i] == 'F')
				System.out.println(i + "회차 시간은 예약가능합니다.");
		}
		System.out.println("------------------------------------------------");
	}
}
